package com.ruoyi.web.controller.lynhgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lynhgl.domain.TbLynhglLssjcx;
import com.ruoyi.lynhgl.service.ITbLynhglLssjcxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 历史数据查询Controller
 * 
 * @author hc
 * @date 2023-11-10
 */
@RestController
@RequestMapping("/lynhgl/lssjcx")
public class TbLynhglLssjcxController extends BaseController
{
    @Autowired
    private ITbLynhglLssjcxService tbLynhglLssjcxService;

    /**
     * 查询历史数据查询列表
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lssjcx:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbLynhglLssjcx tbLynhglLssjcx)
    {
        startPage();
        List<TbLynhglLssjcx> list = tbLynhglLssjcxService.selectTbLynhglLssjcxList(tbLynhglLssjcx);
        return getDataTable(list);
    }

    /**
     * 导出历史数据查询列表
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lssjcx:export')")
    @Log(title = "历史数据查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbLynhglLssjcx tbLynhglLssjcx)
    {
        List<TbLynhglLssjcx> list = tbLynhglLssjcxService.selectTbLynhglLssjcxList(tbLynhglLssjcx);
        ExcelUtil<TbLynhglLssjcx> util = new ExcelUtil<TbLynhglLssjcx>(TbLynhglLssjcx.class);
        util.exportExcel(response, list, "历史数据查询数据");
    }

    /**
     * 获取历史数据查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lssjcx:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbLynhglLssjcxService.selectTbLynhglLssjcxById(id));
    }

    /**
     * 新增历史数据查询
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lssjcx:add')")
    @Log(title = "历史数据查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbLynhglLssjcx tbLynhglLssjcx)
    {
        return toAjax(tbLynhglLssjcxService.insertTbLynhglLssjcx(tbLynhglLssjcx));
    }

    /**
     * 修改历史数据查询
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lssjcx:edit')")
    @Log(title = "历史数据查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbLynhglLssjcx tbLynhglLssjcx)
    {
        return toAjax(tbLynhglLssjcxService.updateTbLynhglLssjcx(tbLynhglLssjcx));
    }

    /**
     * 删除历史数据查询
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lssjcx:remove')")
    @Log(title = "历史数据查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbLynhglLssjcxService.deleteTbLynhglLssjcxByIds(ids));
    }
}
